#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int n,l,r,k,ans=0;
	cin>>n>>l>>r;
	for(int i=l;i<=r;i++)
	{
		int t=i%n;
		if(t>ans)
		{
			ans=t;
		}
	}
	cout<<ans;
	fclose(stdin);
	fclose(stdout);
}
